package com.easy.service.impl;

import com.easy.bean.User;
import com.easy.dao.UserDao;
import com.easy.service.IShoppingLoginService;
import com.easy.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShoppingLoginService implements IShoppingLoginService {

    @Autowired
    UserDao userDao;
    @Override
    public User dologin(User user) {
        User user_data=userDao.getUserByUsername(user.getUsername());
        if(user_data==null){
            throw new RuntimeException("没有此账号");
        }

        if(!SYS.checkPass(user.getPassword(),user_data.getPassword())){
            throw new RuntimeException("密码不正确");
        }
        return user_data;
    }
}
